const normalResult = require("../../js/normalResult.js");
let result = JSON.parse(normalResult)
let config = require('../../js/config.js');
const OSS = require('ali-oss');

module.exports = {
    // http://localhost:9024/manage/tetUpload
    // 上传指定文件，测试一下就好，不要调用
    tetUpload: async (request, response) => {
        try {
            const client = new OSS(config.ossConfig);
            const localFilePath = 'C:/Users/youzh/Desktop/a.png';  // request.body.filePath ||
            const objectName = 'a12.png';  // request.body.objectName ||
            const ossResult = await client.put(objectName, localFilePath);
            console.log('上传成功', ossResult);
            return response.success(Object.assign(result, {data: ossResult}));
        } catch (err) {
            console.error('上传失败', err);
            return response.success(Object.assign(result, {data: '上传失败'}));
        }
    },

}